// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './vuex/store'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/js/bootstrap.min.js'
import axios from 'axios'

import VueHtml5Editor from 'vue-html5-editor'
import 'font-awesome/css/font-awesome.css'

Vue.config.productionTip = false

//设置axios默认Url地址前缀
axios.defaults.baseURL = "http://localhost:8081/blog/"
//全局注册，使用方法为:this.$axios
Vue.prototype.$axios = axios

new Vue({
  el: '#app',
  router,
  store,//使用store
  components: { App },
  template: '<App/>'
})

//定义全局变量$imageUrl,图片服务器地址前缀
Vue.prototype.$imageUrl = "http://localhost:8081/blog/"

Vue.use(VueHtml5Editor, {
  showModuleName: false,
  image: {
    // 文件最大体积，单位字节  max file size
    sizeLimit: 512 * 1024,
    //图片压缩
    compress: true,
    width: 500,
    height: 500,
    quality: 80,

    // 上传参数,默认把图片转为base64而不上传
    // upload config,default null and convert image to base64
    upload: {
      url: 'http://localhost:8081/blog/file',
      headers: {},
      params: {},
      fieldName: 'myfile'
    },
    // 响应数据处理,最终返回图片链接
    // handle response data，return image url
    uploadHandler(responseText) {
      // default accept json data like  {ok:false,msg:"unexpected"} or {ok:true,data:"image url"}
      let response = JSON.parse(responseText)
      return 'http://localhost:8081/blog/' + response.data;
    }
  }
})
